#include <QApplication>
#include "control_panel.h"
#include "my_application.h"

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);

    control_panel w;
    w.show();

#if 0
    QWidget w;

    auto h_widget = new QWidget();
    auto h_layout = new QHBoxLayout(h_widget);
    auto label = new QLabel("AAAAAAAAA");
    h_layout->addWidget(label);
    auto le = new QLineEdit();
    h_layout->addWidget(le);
    h_widget->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Maximum);

    auto table = new QTableView();
    table->setMinimumHeight(200);
    table->setMaximumHeight(600);
    table->setMinimumWidth(600);
    table->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::MinimumExpanding);
//    QObject::connect(table->horizontalHeader(), SIGNAL(sectionResized(int, int, int)), table, SLOT(resizeRowsToContents()));

    auto model = new QStandardItemModel(table);
    table->setModel(model);
//    table->setWordWrap(true);
    table->horizontalHeader()->setStretchLastSection(true);

    QList<QStandardItem*> items;
    for (int i = 0; i < 2; ++i)
        items << new QStandardItem("AAAAAAAAAAAAAAAAAAAA\nAAAAAAAAAAAAAAAAAAAA\nAAAAAAAAAAAAAAAAAAAA\nAAAAAAAAAAAAAAA\nAAAAAAAAAAAAAAAAAAA");
    model->appendRow(items);

    table->resizeRowsToContents();
    table->resizeColumnsToContents();

    auto lay = new QVBoxLayout(&w);
    lay->setSizeConstraint(QLayout::SetMinAndMaxSize);
    lay->addWidget(table);
    lay->addWidget(h_widget);
    w.setLayout(lay);

    w.show();
#endif

    return a.exec();
}

/* work variant
    QWidget w;

    auto label = new QLabel("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA");
    label->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum);

    auto table = new QTableView();
    table->setMinimumHeight(200);
    table->setMaximumHeight(600);
    table->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::MinimumExpanding);

    auto lay = new QVBoxLayout(&w);
    lay->setSizeConstraint(QLayout::SetMinAndMaxSize);
    lay->addWidget(table);
    lay->addWidget(label);
    w.setLayout(lay);

    w.show();
*/

/* another working variant
    QWidget w;

    auto h_widget = new QWidget();
    auto h_layout = new QHBoxLayout(h_widget);
    auto label = new QLabel("AAAAAAAAA");
    h_layout->addWidget(label);
    auto le = new QLineEdit();
    h_layout->addWidget(le);
    h_widget->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Maximum);

    auto table = new QTableView();
    table->setMinimumHeight(200);
    table->setMaximumHeight(600);
    table->setMinimumWidth(600);
    table->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::MinimumExpanding);

    auto lay = new QVBoxLayout(&w);
    lay->setSizeConstraint(QLayout::SetMinAndMaxSize);
    lay->addWidget(table);
    lay->addWidget(h_widget);
    w.setLayout(lay);

    w.show();
*/
